package com.guaoran.interview.spring.source;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author : 孤傲然
 * @description : TODO 加上描述吧
 * @date :2024/3/1 17:20
 */
@Component
public class SourceBeanPostProcessor implements BeanPostProcessor {
    public SourceBeanPostProcessor() {
        System.out.println();
    }

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.contains("beanLifeCycleSource")) {
            System.err.println("SourceBeanPostProcessor#postProcessBeforeInitialization:" + beanName + "---");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.contains("beanLifeCycleSource")) {
            System.err.println("SourceBeanPostProcessor#postProcessAfterInitialization:" + beanName + "---");
        }
        return bean;
    }
}
